package com.kofigyan.stateprogressbarsample;

import com.kofigyan.stateprogressbar.StateProgressBar;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.custom.UserDetailsView;
import com.kofigyan.stateprogressbarsample.not_stateprogressbar.utils.AbilityToAbility;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;

public class UsageDetailsActivity extends UsageBaseActivity
        implements UserDetailsView.OnUserDetailClickListener {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.ONE);
        setupUserDetailsView();
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_usage_details;
    }

    @Override
    public void onUserDetailClickListener(Component v) {
        switch (v.getId()) {
            case ResourceTable.Id_udvName:
                new ToastDialog(this).setText("User Name Detail Clicked")
                        .setDuration(1000).show();
                break;
            case ResourceTable.Id_udvEmail:
                new ToastDialog(this).setText("User Email Detail Clicked")
                        .setDuration(1000).show();
                break;
            case ResourceTable.Id_udvPhoneNumber:
                new ToastDialog(this).setText("User Phone Number Detail Clicked")
                        .setDuration(1000).show();
                break;
            case ResourceTable.Id_udvPassword:
                new ToastDialog(this).setText("User Password Detail Clicked")
                        .setDuration(1000).show();
                break;
        }
    }

    @Override
    public void onClick(Component component) {
        AbilityToAbility.toAbility(this, UsagePricingActivity.class);
    }

    private void setupUserDetailsView() {
        setupUserDetailsView(ResourceTable.Id_udvName);
        setupUserDetailsView(ResourceTable.Id_udvEmail);
        setupUserDetailsView(ResourceTable.Id_udvPhoneNumber);
        setupUserDetailsView(ResourceTable.Id_udvPassword);
    }

    private void setupUserDetailsView(int viewId) {
        UserDetailsView udvView = (UserDetailsView) findComponentById(viewId);
        udvView.setOnUserDetailClickListener(this);
    }
}
